/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.eisti.icc.zk;

import java.util.HashMap;
import java.util.Map;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.ext.AfterCompose;
import org.zkoss.zul.Hlayout;
import org.zkoss.zul.Panel;
import org.zkoss.zul.Vlayout;

/**
 *
 * @author rogers
 */
public class MenuController extends Panel implements AfterCompose {
    
    private Hlayout docSelectedItem;
    private Hlayout docSelected;
    private Hlayout administration;
    
    public void afterCompose() {
        Components.wireVariables(this, this);
        Components.addForwards(this, this);
    }
        
    public void getDocuments(String type) {
       
        if (docSelectedItem.getChildren().size() > 0) {
            docSelectedItem.removeChild(docSelectedItem.getChildren().get(0));
        }
        
        Map data = new HashMap();
        data.put("type", type);
        
        docSelectedItem.appendChild(
                (Vlayout) Executions.createComponents("affichageDocuments.zul", null, data));
        
        docSelected.setVisible(false);
        administration.setVisible(false);
        docSelectedItem.setVisible(true);
    }
    
    public void administration() {
        
        if (administration.getChildren().size() > 0) {
            administration.removeChild(administration.getChildren().get(0));
        }
        
        administration.appendChild(
                (Hlayout) Executions.createComponents("administration.zul", null, null));
        
        docSelected.setVisible(false);
        docSelectedItem.setVisible(false);
        administration.setVisible(true);
        
    }
}
